from tkinter import *
import time
import numpy as np
from dm import dm
import user as us

#画窗口
root = Tk()
root.geometry('1000x500')
root.resizable(False, False)
graph = Canvas(root, width=1000, height=550, background='black')#后面查点和删点的时候需要画布类
graph.grid()
hwnd = dm.FindWindow("","地下城与勇士") 
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)
dm.MoveWindow(hwnd,0,0)
dm_ret = dm.SetDict(0,'./word/怪物字库.txt')
yx_start_pos = None

# while True:
#     # 765 566 游戏相对位置
#     yx_start_pos = dm.FindPic(0,0,2000,2000,'./nyz_dt/init_pos.bmp',"000000",0.9,3)
#     if yx_start_pos[0]!=-1:
#         yx_start_pos = (yx_start_pos[1]-765,yx_start_pos[2]-566)
#         break
#     else:
#         print("获取游戏初始位置失败")
# us.move_to_target(1021,359)
while(True):
    x,y,is_fight = us.user_hbl_real_pos()
    x = x//10
    y = y//10
    graph.create_line(x, y, x+1, y+1, fill="white")
    root.update_idletasks()
    root.update()#更新显示